import pymysql

# 创建连接
# 连接到数据库
conn = pymysql.connect(host='localhost',port=3306,user='root',passwd='root',db='books',charset='utf8')

# 获取游标
cursor = conn.cursor()

# 执行sql
sql = "update t_book set title='东游记' where title = '西游记';"
cursor.execute(sql)

cursor.close()

conn.close()

